package com.example.demo.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @Description: 视图
 * @author: liyuan
 * @data 2020-11-20 14:39
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class ResultVO<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    private Integer status;

    private T data;

    public ResultVO(Integer status) {
        this(status, null);
    }

    /***
     * 成功的状态码
     * @return
     */
    public static ResultVO<Object> ok() {
        return new ResultVO<>(1000);
    }

    /***
     * 失败的状态码
     * @return
     */
    public static ResultVO<Object> error() {
        return new ResultVO<>(2000);
    }

    /***
     * 失败，即区分于服务器错误
     * @return
     */
    public static ResultVO fail() {
        return new ResultVO<>(1002);
    }
}

